<?php session_start();
include("3.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="php, codigo fuente, codigo escrito, descarga gratis, AJAX, javascript, MySQL, scripts, rincondelcodigo, google maps" />
<meta name="ROBOTS" content="NOARCHIVE" />
<title>mapas google</title>
<!--www.rincondelcodigo.com-->
</head>
<body onload="initialize()" onunload="GUnload()" id="home">
PASO 2: Una vez que el usuario se ha registrado o a iniciado sesion accede a esta pagina.<br>
Para geolocalizarse en el mapa clicka en el lugar desde donde procede y le saldr un icono. Debera pulsar sobre el icono<br>
y para finalizar geolocalizarse.<br><br>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
  <!--script src="http://maps.google.com/maps?file=api&v=2.x&key=ABQIAAAAaOuNwQpl_6SNrN9SPqlprhQmVl4M6pUqpH8m1u86xCFJGE2ovxS4R4LhSaw6omab-H9GhhvM5WdLMw"
            type="text/javascript"></script-->
			<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true_or_false&amp;key=ABQIAAAAPb4b93wYVqUFBZeehAZ2iRR7ISGC-z8PG00L_ggG4gkfUQn6vxSPuL2i_Ax2fvftm9tXktcBLtG16A" type="text/javascript"></script>
...
    <script type="text/javascript">
	    function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(43.31993254700499, -1.9854354858398438), 2);
		map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());

GEvent.addListener(map, "click", function(overlay, latlng) {
 var marker = new GMarker(latlng)
 map.addOverlay(marker);
 })
                  
        GEvent.addListener(map, "moveend", function() {
          var center = map.getCenter();
          document.getElementById("message").innerHTML = center.toString();
        });
   GEvent.addListener(map, "click", function(overlay, latlng) {
          if (latlng) {
            marker = new GMarker(latlng, {draggable:true});
            GEvent.addListener(marker, "click", function() {
              var html = "<dl class='categorylist'><dt>Hola <?php echo $_SESSION['estado']; ?>.<br>Pulsa el botn para geolocalizarte.<br><br>" +
                        "<input type='button' value='Geolocalizar' onclick='saveData()'/></dt></dl><br><br><br><br>";

              marker.openInfoWindow(html);
            });
            map.addOverlay(marker);
          }
        });

      }
    }

    function saveData() {
     
      var latlng = marker.getLatLng();
      var lat = latlng.lat();
      var lng = latlng.lng();
	  var url = "5.php?lat=" + lat + "&lng=" + lng + "&id=<?php echo $id; ?>";
      GDownloadUrl(url, function(data, responseCode) {
        if (responseCode == 200 && data.length <= 1) {
        window.location="4.php"; 
        }
      });
    }
    </script>
<div id="map_canvas" style="width: 700px; height: 500px"></div>
    <div id="message"></div>
</body></html>